//
//  DiscoverClassifyTableViewCellThird.m
//  XYFMApp
//
//  Created by 岁变 on 16/9/7.
//  Copyright © 2016年 岁变. All rights reserved.
//

#import "DiscoverClassifyTableViewCellThird.h"
#import "XYMacro.h"


@implementation DiscoverClassifyTableViewCellThird

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        _picImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_picImageView];
        
        _backImageVeiw = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login_channel_item"]];
        [self.contentView addSubview:_backImageVeiw];
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = [UIColor whiteColor];
        [_backImageVeiw addSubview:_titleLabel];
        
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.textColor = [UIColor colorWithRed:0.44 green:0.44 blue:0.48 alpha:1.00];
        _contentLabel.font = [UIFont systemFontOfSize:14];
        [_backImageVeiw addSubview:_contentLabel];
        
        _playImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"catinfo_play_cnt"]];
        [_backImageVeiw addSubview:_playImageView];
        
        _numberLabel = [[UILabel alloc] init];
        _numberLabel.textColor = [UIColor colorWithRed:0.44 green:0.44 blue:0.48 alpha:1.00];
        _numberLabel.font = [UIFont systemFontOfSize:14];
        [_backImageVeiw addSubview:_numberLabel];
        
        _fromLabel = [[UILabel alloc] init];
        _fromLabel.textColor =[UIColor colorWithRed:0.44 green:0.44 blue:0.48 alpha:1.00];
        _fromLabel.font = [UIFont systemFontOfSize:14];
        [_backImageVeiw addSubview:_fromLabel];
                
    }
    return self;
}

- (void)setModel:(ClassifyModelSecondData *)model {
    _model = [[ClassifyModelSecondData alloc] init];
    _model = model;
    
    _numberLabel.text = [NSString stringWithFormat:@"%ld", model.item_views];
    [_picImageView sd_setImageWithURL:[NSURL URLWithString:model.item_img] placeholderImage:PLACEHOLDERIMAGE];
    _titleLabel.text = model.item_name;
    _contentLabel.text = model.item_desc;
    _fromLabel.text = [NSString stringWithFormat:@"by %@", model.item_manager];
}



- (void)layoutSubviews {
    
    [super layoutSubviews];
    [_backImageVeiw mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(0);
        make.top.equalTo(self.contentView.mas_top).with.offset(10);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_backImageVeiw.mas_top).with.offset(5);
        make.left.equalTo(self.contentView.mas_left).with.offset(130);
        make.width.mas_offset(100);
        make.height.mas_offset(30);
    }];
    
    [_playImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).with.offset(130);
        make.bottom.equalTo(_backImageVeiw.mas_bottom).with.offset(-10);
        make.height.mas_offset(10);
        make.width.mas_offset(10);
    }];
    
    
    [_numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo (self.playImageView.mas_right).with.offset(2);
        make.width.mas_offset(50);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-8);
        make.height.mas_offset(15);
    }];
    
    [_fromLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_numberLabel.mas_right).with.offset(20);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-8);
        make.height.mas_offset(15);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
    }];
    
    [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).with.offset(130);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
        make.top.equalTo(self.titleLabel.mas_bottom).with.offset(10);
        make.height.mas_offset(15);
    }];
    
    
    [_picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).with.offset(0);
        make.top.equalTo(self.contentView.mas_top).with.offset(10);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(0);
        make.width.mas_offset(85);
    }];
    
    
    
    
}



@end
